package com.woniu.adopt_web.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.adopt_web.service.TeamService;
import com.woniu.adopt_web.vo.TeamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@Controller
@RequestMapping("team")
public class TeamController {

    @Autowired
    TeamService teamService;

    /**
     * 我的团队信息展示
     *
     * @param now  当前页
     * @param size 页大小
     * @param name 团队成员名
     * @return
     */
    @GetMapping("/teamList")
    public String queryTeam(@RequestParam(value = "now", defaultValue = "1") Integer now,
                            @RequestParam(value = "size", defaultValue = "20") Integer size,
                            String name, Map<String, java.util.List<TeamVo>> map) {
        PageInfo<TeamVo> result = null;

        try {
            result = teamService.queryTeamByPage(now, size, name);
            map.put("teamList", result.getList());
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
        if (name != null) {
            return "teamDetail";
        }
        return "team";
    }

}
